// ==UserScript==
// @name         AcFun小助手
// @namespace    https://github.com/maijz128
// @version      0.1.0
// @description  文章区：评论区域居中、文章内容始终显示、高亮楼主名字；
// @author       MaiJZ
// @match        *://*.acfun.cn/a/*
// @grant        none
// ==/UserScript==

const IS_DEBUG = false;
const v = {};

(function () {
    initVar();
    main();
})();

function initVar() {
    const repository = 'http://maijz.gitee.io/acfunhelper/public';
    const localhost = 'http://localhost:8080';
    const HOST = IS_DEBUG ? localhost : repository;

    v.Styles = [
        HOST + '/index.bundle.css'
    ];
    v.Scripts = [
        HOST + '/index.bundle.js'
    ];
}

function main() {
    loadStyles();
    loadScripts();
}

function loadStyles() {
    const elContainer = document.head;

    for (let index = 0; index < v.Styles.length; index++) {
        const styleURL = v.Styles[index];

        const elStyle = document.createElement('link');
        elStyle.setAttribute('href', styleURL);
        elStyle.setAttribute('rel', 'stylesheet');
        elStyle.setAttribute('type', 'text/css');

        elContainer.appendChild(elStyle);
    }
}

function loadScripts() {
    const CONTAINER_ID = 'script-container';
    const elContainer = document.createElement('div');
    elContainer.setAttribute('id', CONTAINER_ID);
    document.body.appendChild(elContainer);


    for (let index = 0; index < v.Scripts.length; index++) {
        const scriptURL = v.Scripts[index];

        const elScript = document.createElement('script');
        elScript.src = scriptURL;
        elContainer.appendChild(elScript);
    }
}